home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / fpc / compiler / pexports.pas < prev    next >
Pascal/Delphi Source File  |  1998-09-24  |  5KB  |  162 lines

  1. {
  2.     $Id: pexports.pas,v 1.1.1.1 1998/03/25 11:18:15 root Exp $
  3.     Copyright (c) 1998 by Florian Klaempfl
  4.  
  5.     This unit handles the exports parsing
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  ****************************************************************************
  22. }
  23. unit pexports;
  24.  
  25.   interface
  26.  
  27.     { reads an exports statement in a library }
  28.     procedure read_exports;
  29.  
  30.   implementation
  31.  
  32.     uses
  33.        cobjects,globals,scanner,symtable,pbase,verbose;
  34.  
  35.     const
  36.        { export options }
  37.        eo_resident = $1;
  38.  
  39.     type
  40.        pexportsitem = ^texportsitem;
  41.  
  42.        texportsitem = object(tlinkedlist_item)
  43.           sym : psym;
  44.           index : longint;
  45.           name : pstring;
  46.           options : word;
  47.           constructor init;
  48.        end;
  49.  
  50.     var
  51.        exportslist : tlinkedlist;
  52.  
  53.     constructor texportsitem.init;
  54.  
  55.       begin
  56.          sym:=nil;
  57.          index:=-1;
  58.          name:=nil;
  59.          options:=0;
  60.       end;
  61.  
  62.     procedure read_exports;
  63.  
  64.       var
  65.          hp : pexportsitem;
  66.          code : word;
  67.  
  68.       begin
  69.          hp:=new(pexportsitem,init);
  70.          consume(_EXPORTS);
  71.          while true do
  72.            begin
  73.               if token=ID then
  74.                 begin
  75.                    getsym(pattern,true);
  76.                    if srsym^.typ=unitsym then
  77.                      begin
  78.                         consume(ID);
  79.                         consume(POINT);
  80.                         getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  81.                      end;
  82.                    consume(ID);
  83.                    if assigned(srsym) then
  84.                      begin
  85.                         hp^.sym:=srsym;
  86.                         if (srsym^.typ<>procsym) or
  87.                           ((pprocdef(pprocsym(srsym)^.definition)^.options and poexports)=0) then
  88.                           Message(parser_e_illegal_symbol_exported);
  89.                         if (token=ID) and (pattern='INDEX') then
  90.                           begin
  91.                              consume(ID);
  92.                              val(pattern,hp^.index,code);
  93.                              consume(INTCONST);
  94.                           end;
  95.                         if (token=ID) and (pattern='NAME') then
  96.                           begin
  97.                              consume(ID);
  98.                              hp^.name:=stringdup(pattern);
  99.                              consume(ID);
  100.                           end;
  101.                         if (token=ID) and (pattern='RESIDENT') then
  102.                           begin
  103.                              consume(ID);
  104.                              hp^.options:=hp^.options or eo_resident;
  105.                           end;
  106.                      end;
  107.                 end
  108.               else
  109.                 consume(ID);
  110.               if token=COMMA then
  111.                 consume(COMMA)
  112.               else
  113.                 break;
  114.            end;
  115.          consume(SEMICOLON);
  116.       end;
  117.  
  118. begin
  119.    { a library is a root of sources, e.g. it can't be used
  120.      twice in one compiler run }
  121.    exportslist.init;
  122. end.
  123.  
  124. {
  125.   $Log: pexports.pas,v $
  126.   Revision 1.1.1.1  1998/03/25 11:18:15  root
  127.   * Restored version
  128.  
  129.   Revision 1.7  1998/03/10 01:17:24  peter
  130.     * all files have the same header
  131.     * messages are fully implemented, EXTDEBUG uses Comment()
  132.     + AG... files for the Assembler generation
  133.  
  134.   Revision 1.6  1998/03/06 00:52:42  peter
  135.     * replaced all old messages from errore.msg, only ExtDebug and some
  136.       Comment() calls are left
  137.     * fixed options.pas
  138.  
  139.   Revision 1.5  1998/03/02 01:49:01  peter
  140.     * renamed target_DOS to target_GO32V1
  141.     + new verbose system, merged old errors and verbose units into one new
  142.       verbose.pas, so errors.pas is obsolete
  143.  
  144.   Revision 1.4  1998/02/13 10:35:24  daniel
  145.   * Made Motorola version compilable.
  146.   * Fixed optimizer
  147.  
  148.   Revision 1.3  1998/01/12 13:02:41  florian
  149.     + items of exports are now seperated by ,
  150.  
  151.   Revision 1.2  1998/01/12 12:11:35  florian
  152.     + unit qualifier is now allowed to specify exported symbols
  153.     + exports starts now a list of symbols to export
  154.  
  155.   Revision 1.1  1998/01/11 10:58:07  florian
  156.     + pexports in lowercase commited
  157.  
  158.   Revision 1.1  1998/01/11 10:54:19  florian
  159.     + generic library support
  160.  
  161. }
  162.